function getCode(e){
    checkPhone(); //验证手机号码
}
function getCode2(e){
    resetCode(); //倒计时
}
function sendCode(e){
    send(); //验证手机号码
    if(isPhone)
    {
       //发送验证码 返回成功后启用倒计时
    }
}
//发送验证码按钮触发
function send(){
    var phone = $('#phone').val();
    var pattern = /^1(3|4|5|7|8)\d{9}$/;
    isPhone = 1;
    if(phone == '') {
        layer.open({
            content: '请输入手机号码'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
        isPhone = 0;
        return false;
    }else if(!pattern.test(phone)){
        layer.open({
            content: '请输入正确的手机号码'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2 //2秒后自动关闭
        });
        isPhone = 0;
        return false;
    }else{
    	return true;
    }
}
//验证手机号码
function checkPhone(){
    var phone = $('#phone').val();//手机号
    var pwd = $('#pass1').val();
    var pwd_1 = $('#pass2').val();
    var pwd_2 = $('.pass2').val();
    var code = $('#code').val();//验证码
    var pattern = /^1(3|4|5|7|8)\d{9}$/;//手机号格式
    var patrn=/^(\w){6,20}$/;//密码格式
    isPhone = 1;
    if(phone == '') {
        layer.open({
            content: '请输入手机号码'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        isPhone = 0;
        return false;
    }
    if(!pattern.test(phone)){
        layer.open({
            content: '请输入正确的手机号码'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        isPhone = 0;
        return false;
    }
    if(code == ''){
        layer.open({
            content: '请输入有效验证码！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    if(pwd== ''){
        layer.open({
            content: '密码不能为空'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    if(pwd_1== ''){
        layer.open({
            content: '确认密码不能为空'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    if(!patrn.test(pwd)){
        layer.open({
            content: '请确认，密码为6-20位数字或者字母！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        isPhone = 0;
        return false;
    }
    if(pwd_2 != pwd_1){
        layer.open({
            content: '请确认，密码是否输入一致'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }   
    return true;
}
//修改密码
function yzeditpwd(){
    var pwd = $('#pass1').val();
    var pwd_1 = $('#pass2').val();
    var pwd_2 = $('.pass2').val();
    var code = $('#code').val();
    var patrn=/^(\w){6,20}$/;
    isPhone = 1;
    if(code == ''){
        layer.open({
            content: '请输入有效验证码验证码！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    if(pwd== ''){
        layer.open({
            content: '密码不能为空！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    if(pwd_1== ''){
        layer.open({
            content: '确认密码，不能为空！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    if(!patrn.test(pwd)){
        layer.open({
            content: '请确认，密码为6-20位数字或者字母！'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        isPhone = 0;
        return false;
    }
    if(pwd_2 != pwd_1){
        layer.open({
            content: '请确认，密码是否输入一致'
            ,className: 'popuo-login'
            ,skin: 'msg'
            ,time: 2
        })
        return false;
    }
    return true;
}
//倒计时
 var timer;
    function resetCode(){
        clearInterval(timer);
        $('#J_getCode').hide();
        $('#J_second').html(60);
        $('#J_resetCode').show();
        var second = 60;
            timer = setInterval(function(){
                second -= 1;
                if(second >=0 ){
                    $('#J_second').html(second);
                }
                if(second <0 ){
                    clearInterval(timer);
                    $('#J_getCode').show();
                    $('#J_resetCode').hide();
                }
            },1000);
    }

//点击多选框切换text和password的隐藏和显示
function showHidePassword() {
    $("#text").toggle();
    $("#text1").toggle();
    $(".judge").toggle();
    $(".judge1").toggle();
}
//text框失去焦点把text框的值赋值给password框
function textBlur() {
    $(".judge").val($("#text").val());
    $(".judge1").val($("#text1").val());
}
//password框失去焦点把password框的值赋值给text框
function passwordBlur() {
    $("#text").val($(".judge").val());
    $("#text1").val($(".judge1").val());
}
//判断是不显示密码
$('body').on('click','#togglePassword',function(){
    $(this).toggleClass("active");
})
//清空手机号
function textclean(){
    var txtclean= document.getElementById("phone");
    txtclean.value="";
}
//同意协议注册
function abc(){
	if(document.getElementById("agreement").checked == false){
		layer.open({
	        content: '不同意协议不能注册'
	        ,className: 'popuo-login'
	        ,skin: 'msg'
	        ,time: 2
	    })
		return false;
	}
}

